package  
{
	import flash.display.*;
	import flash.events.*;
	import iks.utils.geom.*;
	import ve.*;
	
	public final class FlockTest extends Sprite 
	{
		
		public function FlockTest() 
		{
			m_vehicles = new Vector.<Vehicle>(2, true);
			for (var i : int = 0; i < m_vehicles.length; ++i)
			{
				var vehicle : Vehicle = new SteeredVehicle();
				vehicle.edgeBehavior = Vehicle.BOUNCE;
				vehicle.position = new Vector2D(Math.random() * this.stage.stageWidth, Math.random() * this.stage.stageHeight);
				vehicle.velocity = new Vector2D((Math.random() - 0.5) * 20, (Math.random() - 0.5) * 20);
				m_vehicles[i] = vehicle;
				this.addChild(vehicle);
			}
			
			m_head = new SteeredVehicle(0xff0000);
			//m_head.edgeBehavior = Vehicle.BOUNCE;
			m_head.position = new Vector2D(Math.random() * this.stage.stageWidth, Math.random() * this.stage.stageHeight);
			m_head.velocity = new Vector2D((Math.random() - 0.5) * 30, (Math.random() - 0.5) * 30);
			this.addChild(m_head);
			
			this.addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
		}
		
		private function onEnterFrameHandler(evt : Event) : void
		{
			//m_head.wander();
			//m_head.update();
			for each (var v : SteeredVehicle in m_vehicles)
			{
				//v.seek(m_head.position.clone());
				v.flock(m_vehicles);
				v.update();
			}
		}
		
		private var m_head		: SteeredVehicle = null;
		private var m_vehicles	: Vector.<Vehicle> = null;
		
	}

}

































///////////////////////////////////////////////////////////////////////////////////////////////////
// end file